package com.AC.ACDangDang;

import java.util.Scanner;

/**
 * 第一题
 */
public class test1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i<n; i++){
            arr[i] = sc.nextInt();
        }
        sc.close();
        System.out.println(getNum2(arr,k));
    }

    public static int getNum(int[] arr, int k){
        if(arr.length == 0 || k == 0)
            return 0;
        int mod = 1000000007;
        int len = arr.length;
        long[] dp = new long[len+1];//前缀积
        dp[0] = 0;
        dp[1] = arr[0];
        for(int i = 2; i<=len; i++){
            dp[i] = (dp[i-1] + arr[i-1]) % mod;
        }

        int res = 0;

        //枚举每一段长度的数字积
        for(int i = 1; i <= len; i++){
            for(int j = 0; j + i <= len; j++){
                if((dp[j+i] - dp[j]) % k == 0){
                    res++;
                }

            }
        }

        return res;
    }

    public static int getNum2(int[] arr , int k){
        int res = 0;
        for(int i = 1; i<arr.length; i++){
            for(int j = 0; j+i < arr.length; j++){
                int curSum = 0;
                for(int z = j; z<=j+i; z++){
                    curSum += arr[z];
                }
                if(curSum % k == 0)
                    res++;
            }
        }
        return res;
    }


}
